<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .red{
            background-color: red;
        }
    </style>
</head>

<body>
    <div id="app">
        <cars-list :cars='cars'>
            <template slot-scope="slotProps">
                <p v-if="slotProps.info.id==2" class="red">
                    {{slotProps.info.name}}
                </p>
                <p v-else>{{slotProps.info.name}}</p>
            </template>
        </cars-list>
    </div>
    <script src="../node_modules/vue/dist/vue.js"></script>
    <script>
        Vue.component('cars-list', {
            props: ['cars'],
            template: `
                <div>
                    <ul>
                        <li :key='item.id' v-for='item in cars'>
                            <slot :info='item'></slot>
                        </li>    
                    </ul>
                </div>
            `
        })
        new Vue({
            el: '#app',
            data() { 
                return {
                    cars: [
                        {
                            id: 1,
                            name: '宝马'
                        }, {
                            id: 2,
                            name: '奔驰'
                        }, {
                            id: 3,
                            name: '奥迪'
                        },
                    ]
                }
            },
        })
    </script>
</body>

</html>